package com.bt.springboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @author zkx
 * @Date 2024/1/19 17:17
 */
@Configuration
public class AsyncConfig {

	@Bean("asyncTaskExecutor")
	public Executor asyncTaskExecutor() {
		ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
		// 核心线程数
		executor.setCorePoolSize(10);
		// 最大线程数
		executor.setMaxPoolSize(20);
		// 队列最大长度
//		executor.setQueueCapacity(10000);
		// 设置线程名
		executor.setThreadNamePrefix("Async-Task");
		return executor;
	}

}
